﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DAL;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    //添加
    protected void btnOK_Click(object sender, EventArgs e)
    {
        add();
    }

    //添加
    private void add()
    {
        if (!isEmpty() == false)
        {
            using (DataClassesDataContext lqDB = new DataClassesDataContext())
            {
                Approal approals = new Approal();
                approals.ID = DateTime.Now.ToString("yyyyMMddHHmmssff");
                approals.Approal_ID = txtID.Text;
                approals.Approal_Title = txtTitle.Text;
                approals.Approal_Date = txtDate.Text;
                approals.Approal_Summary = txtRemark.Text;
                approals.ComminityID = this.cmbComminity.SelectedItem.Value.ToString();
                lqDB.Approal.InsertOnSubmit(approals);
                lqDB.SubmitChanges();
                Frame.Global.GlobalFunctions.AlertToUrl("添加成功！", "ApproalManager.aspx");
            }
        }
    }
    //判断是否为空
    private bool isEmpty()
    {
        bool isempty = true;
        if (this.txtID.Text.Equals(""))
        {
            Frame.Global.GlobalFunctions.Alert("批文文号不能为空！");
            isempty = false;
        }
        else if (this.txtTitle.Text.Equals(""))
        {
            Frame.Global.GlobalFunctions.Alert("批文标题不能为空！");
            isempty = false;
        }
        else if (this.cmbComminity.Text.Equals(""))
        {
            Frame.Global.GlobalFunctions.Alert("请选择社区！");
            isempty = false;
        }
        else if (this.txtRemark.Text.Equals(""))
        {
            Frame.Global.GlobalFunctions.Alert("批文摘要不能为空！");
            isempty = false;
        }
        else if (this.txtDate.Text.Equals(""))
        {
            Frame.Global.GlobalFunctions.Alert("批文日期不能为空！");
            isempty = false;
        }
        else
        {
            isempty = true;
        }
        return isempty;
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("ApproalManager.aspx");
    }
}